package com.mind.ridge.controller;

import com.mind.ridge.service.backend.CommonService;
import com.mind.ridge.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Mind
 */
@RestController
@Slf4j
@RequestMapping("/common")
public class CommonController {

    @Resource
    private CommonService commonService;

    @PostMapping("/upload")
    public R<String> upload(MultipartFile file){
        return commonService.upload(file);
    }

    @GetMapping("/download")
    public void download(String name, HttpServletResponse response){
        commonService.download(name, response);
    }
}
